{extend name="main"}
{block name="style"}
<style type="text/css">
	#about{line-height: 1;}
	#container{line-height: 1;}
	.cid-title{font-size: .8rem;font-weight: bold;}
	.el-popover{min-width: auto;}
	.flex,.row{line-height: 1;}
	pre{overflow: visible;}
</style>
{/block}
{block name="body"}
<el-tabs v-model="activeName" class="bg-white px-3">
	<el-tab-pane label="基本信息" name="basic"></el-tab-pane>
	<el-tab-pane label="联系人" name="contacts"></el-tab-pane>
	<el-tab-pane label="详情" name="content"></el-tab-pane>
	<el-tab-pane label="展位" name="booth"></el-tab-pane>
</el-tabs>
<div class="bg-white p-3">
	<el-form :model="form" @submit.native.prevent="submitForm" :rules="rules" ref="form" label-width="120px" :label-position="labelPosition">
	<div v-show="activeName=='basic'">
	  <el-form-item label="标题" prop="title">
	    <el-input v-model="form.title" class="col-12 col-sm-4 pl-0 pr-0" placeholder="Name"></el-input>
	  </el-form-item>

	  <el-form-item label="封面" prop="thumb">
		  <el-image
		  	v-if="thumb" 
		  	class="w-100 h-100 mw-200px mh-200px"
		    :src="thumb" 
		    :preview-src-list="[thumb]">
		  </el-image>
	  	  <el-upload
			  class="avatar-uploader"
			  action="/uploadFiles"
			  name="file"
			  accept="image/*"
			  :data="{path:'job_fair/thumb'}"
			  :show-file-list="false"
			  :on-success="handleAvatarSuccess"
			  :on-error="handleAvatarError">
	  			<el-button size="small" type="primary">选择文件(200*200px)</el-button>
		  </el-upload>
	  </el-form-item>

	  <el-form-item label="横幅" prop="banner">
		  <el-image
		  	v-if="banner" 
		  	class="w-100 h-100 mw-200px mh-200px"
		    :src="banner" 
		    :preview-src-list="[banner]">
		  </el-image>
	  	  <el-upload
			  class="avatar-uploader"
			  action="/uploadFiles"
			  name="file"
			  accept="image/*"
			  :data="{path:'job_fair/banner'}"
			  :show-file-list="false"
			  :on-success="handleAvatarSuccess"
			  :on-error="handleAvatarError">
	  			<el-button size="small" type="primary">选择文件(2000*600px)</el-button>
		  </el-upload>
	  </el-form-item>

	  <el-form-item label="报名开始时间" prop="sign_up_start_time">
	    <el-date-picker
	      v-model="form.sign_up_start_time"
	      align="right"
	      type="datetime"
	      format="yyyy-M-d HH:mm:ss"
	      value-format="yyyy-M-d HH:mm:ss"
	      placeholder="选择报名开始时间">
	    </el-date-picker>
	  </el-form-item>

	  <el-form-item label="报名结束时间" prop="sign_up_end_time">
	    <el-date-picker
	      v-model="form.sign_up_end_time"
	      align="right"
	      type="datetime"
	      placeholder="选择报名结束时间"
	      format="yyyy-M-d HH:mm:ss"
	      value-format="yyyy-M-d HH:mm:ss">
	    </el-date-picker>
	  </el-form-item>

	  <el-form-item label="开始时间" prop="start_time">
	    <el-date-picker
	      v-model="form.start_time"
	      align="right"
	      type="datetime"
	      format="yyyy-M-d HH:mm:ss"
	      value-format="yyyy-M-d HH:mm:ss"
	      placeholder="选择开始时间">
	    </el-date-picker>
	  </el-form-item>

	  <el-form-item label="结束时间" prop="end_time">
	    <el-date-picker
	      v-model="form.end_time"
	      align="right"
	      type="datetime"
	      placeholder="选择结束时间"
	      format="yyyy-M-d HH:mm:ss"
	      value-format="yyyy-M-d HH:mm:ss">
	    </el-date-picker>
	  </el-form-item>

	  <el-form-item label="性质" prop="nature">
	    <el-radio-group v-model="form.nature">
	      <el-radio :label="0">线下线上[默认]</el-radio>
	      <el-radio :label="1">线下</el-radio>
	      <el-radio :label="2">线上</el-radio>
	    </el-radio-group>
	  </el-form-item>

	  <el-form-item label="报名方式">
	  	<el-checkbox v-model="form.online_registration" :true-label="1" :false-label="0">线上报名</el-checkbox>
	  	<el-checkbox v-model="form.tel_registration" :true-label="1" :false-label="0">电话报名</el-checkbox>
	  	<el-checkbox v-model="form.offline_registration" :true-label="1" :false-label="0">线下报名</el-checkbox>
	  </el-form-item>

	  <el-form-item label="允许报名套餐">
	  	<el-checkbox v-model="form.is_all_sign_up" :true-label="1" :false-label="0">全部</el-checkbox>
	  	<el-checkbox-group v-model="form.vip" v-if="!form.is_all_sign_up">
		    <el-checkbox v-for="(v,index) in vip" :label="v.id">{{v.title}}({{v.is_company?'企业':'个人'}})</el-checkbox>
		</el-checkbox-group>
	  </el-form-item>

	  <el-form-item label="排序" prop="sort">
	    <el-input type="number" v-model="form.sort" class="col-12 col-sm-2 pl-0 pr-0" placeholder="排序权重(值越小越在前面)"></el-input>
	  </el-form-item>
	  <el-form-item label="浏览量基数" prop="base_view">
	    <el-input v-model="form.base_view" class="col-12 col-sm-2 pl-0 pr-0" placeholder="浏览量基数，不能小于0"></el-input>
	  </el-form-item>
	  <el-form-item label="浏览人次基数" prop="base_people_sum">
	    <el-input v-model="form.base_people_sum" class="col-12 col-sm-2 pl-0 pr-0" placeholder="不小于0,确保浏览人次<=浏览量"></el-input>
	  </el-form-item>
	  </div>
	  <div v-show="activeName=='contacts'">
		  <el-form-item label="联系人">
		  	<div class="flex mb-1" v-for="(v,index) in form.contacts">
		    	<el-input v-model="v.contacts" class="col-12 col-sm-1 pl-0 pr-0" placeholder="联系人"></el-input>
		    	<div class="col-12 col-sm-2">
			    	<el-input v-model="v.contacts_mobile" placeholder="电话" size="mini">
			    	<template slot="prepend">电话</template>
			    	</el-input>
			    	<el-input v-model="v.contacts_tel" placeholder="座机" size="mini">
			    	<template slot="prepend">座机</template>
			    	</el-input>
			    	<el-input v-model="v.contacts_qq" placeholder="QQ" size="mini">
			    	<template slot="prepend">QQ</template>
			    	</el-input>
			    	<el-input v-model="v.contacts_wechat" placeholder="微信号" size="mini">
			    	<template slot="prepend">微信号</template>
			    	</el-input>
			    	<el-input v-model="v.contacts_email" placeholder="邮箱" size="mini">
			    	<template slot="prepend">邮箱</template>
			    	</el-input>
		    	</div>
		    	<el-input v-model="v.remarks" class="col-12 col-sm-2 pl-0 pr-0 mr-1" placeholder="备注"></el-input>
		  		<div><el-button type="danger" @click="delContacts(v,index)">删除</el-button></div>
		  	</div>
		  	<div>
		  		<el-button size="mini" type="success" @click="addContacts">添加联系人</el-button>
		  		<div class="text-secondary small">电话、QQ、微信号、邮箱全填或填一项均可</div>
		  	</div>
		  </el-form-item>

		  <el-form-item label="地区" prop="job_fair_area">
		    <el-cascader 
		    	v-model="form.job_fair_area"
		    	placeholder="试试搜索：北京"
		    	filterable
				:props="defaultProps"
		    	:options="arealist"
		    	class="w-25">
		    </el-cascader>
		  </el-form-item>
		  <el-form-item label="详细地址" prop="address">
		    <el-input v-model="form.address" class="col-12 col-sm-4 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item label="公交路线" prop="transit">
		    <el-input v-model="form.transit" class="col-12 col-sm-4 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item v-if="amapConfig.status && amapConfig.js_status">
		  	<div id="map_container" style="width: 50%;height: 300px;"></div>
		  </el-form-item>
		  <el-form-item label="联系我们" class="line-height-inherit" prop="content">
			<script id="about" type="text/plain" style="width: 60%;"></script>
		  </el-form-item>
	  </div>
	  <div v-show="activeName=='content'">
		  <el-form-item label="详情" class="line-height-inherit" prop="content">
			<script id="container" type="text/plain" style="width: 60%;"></script>
		  </el-form-item>
	  </div>
	  <div v-show="activeName=='booth'">
		  <el-form-item label="展会平面图" prop="booth_img">
			  <el-image
			  	v-if="booth_img" 
			  	class="w-100 h-100 mw-200px mh-200px"
			    :src="booth_img" 
			    :preview-src-list="[booth_img]">
			  </el-image>
		  	  <el-upload
				  class="avatar-uploader"
				  action="/uploadFiles"
				  name="file"
				  accept="image/*"
				  :data="{path:'job_fair/booth_img'}"
				  :show-file-list="false"
				  :on-success="handleAvatarSuccess"
				  :on-error="handleAvatarError">
		  			<el-button size="small" type="primary">选择文件(1170*600px)</el-button>
			  </el-upload>
		  </el-form-item>
		  <el-form-item label="购买限制" prop="booth_sum">
	    	<el-input-number v-model="form.booth_sum" :step="1" step-strictly :min="1" placeholder="数量"></el-input-number>
		  	<div>
		  		<div class="text-secondary small">一个账号可购买多少个展位</div>
		  	</div>
		  </el-form-item>
		  <el-form-item label="展位">
		  	<div v-for="(v,index) in form.booth">
		  		<div class="flex mb-1">
			    	<el-input v-model="v.name" class="col-12 col-sm-1 pl-0 pr-0" placeholder="展位名称"></el-input>
			    	<el-input v-model="v.identifier" class="col-12 col-sm-1 pl-0 pr-0" placeholder="展位标识符"
			    	@input="initBoothCate(v)"></el-input>
			    	<el-input-number v-model="v.sum" :step="1" step-strictly :min="1" @change="initBoothCate(v)" placeholder="数量" :disabled="is_edit && v.id"></el-input-number>
			    	<el-input v-model="v.price" class="col-12 col-sm-1 pl-0 pr-0" placeholder="价格"
			    	@input="initBoothCate(v)"
			    	:disabled="is_edit && v.id">
			    	<template slot="append">元</template>
			    	</el-input>
			    	<el-input v-model="v.specifications" class="col-12 col-sm-2 pl-0 pr-0" placeholder="规格"
			    	@input="initBoothCate(v)"></el-input>
			  		<el-button class="ml-1" type="danger" @click="delBoothCate(v,index)">删除</el-button>
			  		<el-link class="ml-1" :underline="false"
			  		@click="v.show= !v.show">{{v.show?'收起自定义展位':'展开自定义展位'}}</el-link>
		  		</div>
		  		<div class="row" v-if="v.show">
			  		<div v-for="(va,n) in v.boothCate" class="col-4 col-xl-2 py-1">
			  			<div class="bg-light rounded p-3">
					    	<div class="flex mb-3">
					    		<div class="flex-1">{{v.identifier}}{{va.index}}</div>
						  		<el-popover
									placement="bottom-end"
									trigger="click"
									:disabled="va.id&&va.status!==0">
									<div>
								  		<el-link :underline="false" @click="va.status=0">待售</el-link>
								  		<el-link :underline="false" type="danger" @click="va.status=1">锁定</el-link>
								  		<el-link :underline="false" type="success" @click="va.status=2">已售</el-link>
									</div>
									<div slot="reference">
								  		<el-link :underline="false" v-if="va.status===0">待售</el-link>
								  		<el-link :underline="false" type="danger" v-if="va.status===1">锁定</el-link>
								  		<el-link :underline="false" type="success" v-if="va.status===2">已售</el-link>
									</div>
								</el-popover>
					    	</div>
					    	<el-input v-model="va.price" placeholder="价格" size="mini">
					    	<template slot="append">元</template>
					    	</el-input>
					    	<el-input v-model="va.specifications" placeholder="规格" size="mini"></el-input>
					    	<div class="mt-1 text-right" v-if="v.id">
			  					<el-button type="danger" size="mini" @click="delBooth(va,index,n)">删除</el-button>
					    	</div>
				    	</div>
			  		</div>
			  		<div class="col-4 col-xl-2 py-1" v-if="is_edit && v.id">
			  			<div class="bg-light rounded p-3">
			  				<div class="mb-2">{{v.identifier}}{{v.sum+sum}}</div>
			  				<el-input-number v-model="sum" :step="1" step-strictly :min="1" placeholder="数量"
			  				size="mini"></el-input-number>
			  				<div class="mt-1">
			  					<el-button type="success" size="mini" @click="addBooth(v,index)">追加</el-button>
			  				</div>
				    	</div>
			  		</div>
		  		</div>
		  	</div>
		  	<div>
		  		<el-button size="mini" type="success" @click="addBoothCate">添加展位</el-button>
		  		<div class="text-secondary small">展位名称：如“A区，B区”</div>
		  		<div class="text-secondary small">展位标识符：如“A，B”</div>
		  		<div class="text-secondary small">规格：如“1.3*1.3*2米（长宽高）”</div>
		  		<div class="text-secondary small">当使用线上报名时必须设置展位</div>
		  	</div>
		  </el-form-item>
	  </div>

	  <el-form-item>
	    <el-button type="primary" @click="submitForm('form')">立即保存</el-button>
	    <el-button @click="resetForm('form')">重置</el-button>
	  </el-form-item>
	</el-form>
</div>
<div style="display: none;">
	<div ref="infoWindow">
		<div class="flex">
			<div v-if="thumb" class="pr-2">
				<img :src="thumb" height="60" width="60">
			</div>
			<div>
				<div class="h6">{{form.title}}</div>
				<div class="text-secondary small">{{form.transit}}</div>
				<div class="text-secondary small">{{getAreaText(form.job_fair_area)}}{{form.address}}</div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
{js href="/static/plugin/Ueditor/ueditor.config.js" /}
{js href="/static/plugin/Ueditor/ueditor.all.min.js" /}
{js href="/static/plugin/Ueditor/lang/zh-cn/zh-cn.js" /}
<script type="text/javascript">
	var amapConfig={
		status:{:config('xy_map.status')},
		server_status:{:config('xy_map.server_status')},
		js_status:{:config('xy_map.js_status')},
		js_key:'{:config('xy_map.js_key')}',
	};
	{empty name="arealist"}
	var arealist=[];
	{else/}
	var arealist={:json_encode($arealist,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="vip"}
	var vip=[];
	{else/}
	var vip={:json_encode($vip,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="Find"}
	var url='/job-fair/add';
	var is_edit=false;
	var thumb='';
	var banner='';
	var booth_img='';
	var formData={
			title:'',
			thumb:'',
			banner:'',
			booth_img:'',
			sign_up_start_time:'',
			sign_up_end_time:'',
			start_time:'',
			end_time:'',
			status:0,
			nature:0,
			online_registration:0,
			tel_registration:0,
			offline_registration:0,
			base_view: 0,
			// base_company: 0,
			base_people_sum: 0,
			sort:99,
			is_all_sign_up:1,
			booth_sum:1,
			vip:[],
			booth:[],
			contacts:[],
			job_fair_area:[],
			address:'',
			lng:'',
			lat:'',
			transit:'',
			about:'',
			content:''
		};
	{else/}
	var url='/job-fair/edit/{$Find.id}';
	var is_edit=true;
	var formData={:json_encode($Find,JSON_UNESCAPED_UNICODE)};
	var thumb=formData.thumb?'{:config('web.imgurl')}'+formData.thumb:'';
	var banner=formData.banner?'{:config('web.imgurl')}'+formData.banner:'';
	var booth_img=formData.booth_img?'{:config('web.imgurl')}'+formData.booth_img:'';
	{/empty}
</script>
<script type="text/javascript">
	var map=null;
	var ue = UE.getEditor('container');
	var ueAbout = UE.getEditor('about');
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			labelPosition:'right',
			activeName:'{notempty name=":request()->get('activeName')"}{:request()->get('activeName')}{else/}basic{/notempty}',
			amapConfig:amapConfig,
			vip:vip,
			arealist:arealist,
			form:formData,
			is_edit:is_edit,
	        thumb:thumb,
	        banner:banner,
	        booth_img:booth_img,
	        isSetAboutStatus:false,
			isSetContentStatus:false,
	        sum:1,
	        defaultProps: {
	          	value: 'id',
	          	label: 'title',
	          	children: 'data',
	        },
		    rules: {
		      title: [
		        { required: true, message: '请输入标题', trigger: 'blur' },
		        { min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }
		      ],
		      thumb: [
		        { required: true, message: '请上传封面', trigger: 'change' },
		      ],
		      banner: [
		        { required: true, message: '请上传横幅', trigger: 'change' },
		      ],
		      start_time: [
		        { required: true, message: '请选择开始时间', trigger: 'change' },
		      ],
		      end_time: [
		        { required: true, message: '请选择结束时间', trigger: 'change' },
		      ],
	          status: [
	            { required: true, message: '请选择状态', trigger: 'change' }
	          ],
		    }
		},
		watch:{
		    view:XYBase.viewWatch,
		    activeName(val,oldVal){
		    	switch(val){
		    		case 'contacts':
		    		setTimeout("initAmap();",300)
		    		if(this.isSetAboutStatus)break;
		    		this.isSetAboutStatus=true;
					setTimeout(function(){
						ueAbout.setContent(formData.about);
					},300)
		    		break;
		    		case 'content':
		    		if(this.isSetContentStatus)break;
		    		this.isSetContentStatus=true;
					setTimeout(function(){
						ue.setContent(formData.content);
					},300)
		    		break;
		    	}
		    },
		},
		created(){
			XYBase.created(this);
		},
		methods:{
			addContacts(){
				this.form.contacts.push({
					id:0,
		        	contacts:'',
					contacts_mobile:'',
					contacts_tel:'',
					contacts_qq:'',
					contacts_wechat:'',
					contacts_email:'',
					remarks:''
				});
			},
			delContacts(val,index){
				if(val.id){
		    		var _this=this;
			        _this.$confirm('此操作将永久删除该联系人, 是否继续?', '提示', {
			          confirmButtonText: '确定',
			          cancelButtonText: '取消',
			          type: 'warning'
			        }).then(() => {
			        	$.getJSON('/job-fair/delJobFairContacts/'+val.id,function(ret){
			        		if (ret) {
			        			if (ret.code == 0) {
			        				_this.form.contacts.splice(index,1);
			        			}else{
			        				XYBase.msg(ret.msg);
			        			}
			        		}else{
								XYBase.error(XYBase.config.system_network_error);
			        		}
			        	});
			        }).catch(() => {
	    				XYBase.msg('已取消删除');
			        });
				}else{
					this.form.contacts.splice(index,1);
				}
			},
			addBoothCate(){
				this.form.booth.push({
					id:0,
		        	name:'',
		        	identifier:'',
					sum:'',
					sum_stock:'',
					price:null,
					specifications:'',
					show:false,
					boothCate:[]
				});
			},
			initBoothCate(val){
				if(val.identifier
					&&val.sum
					&&val.price!==null){
					if (this.is_edit&&val.id) {
						for (var i = 0; i <= val.boothCate.length; i++) {
							val.boothCate.identifier=val.identifier
						}
					}else{
						var boothCate=[];
						for (var i = 1; i <= val.sum; i++) {
							boothCate.push({
								index:i,
								price:val.price,
								specifications:val.specifications,
								status:0
							});
						}
						val.boothCate=boothCate;
					}
				}
			},
			delBoothCate(val,index){
				if(val.id){
		    		var _this=this;
			        _this.$confirm('此操作将永久删除该展位, 是否继续?', '提示', {
			          confirmButtonText: '确定',
			          cancelButtonText: '取消',
			          type: 'warning'
			        }).then(() => {
			        	$.getJSON('/job-fair/delJobFairBooth/'+val.id+'/1',function(ret){
			        		if (ret) {
			        			if (ret.code == 0) {
									_this.form.booth.splice(index,1);
			        			}else{
			        				XYBase.msg(ret.msg);
			        			}
			        		}else{
								XYBase.error(XYBase.config.system_network_error);
			        		}
			        	});
			        }).catch(() => {
	    				XYBase.msg('已取消删除');
			        });
				}else{
					this.form.booth.splice(index,1);
				}
			},
			addBooth(val){
				for (var i = 1; i <= this.sum; i++) {
					val.sum++;
					val.boothCate.push({
						id:0,
						index:val.sum,
						price:val.price,
						jid:val.jid,
						identifier:val.identifier,
						specifications:val.specifications,
						status:0
					});
				}
				this.sum=1;
			},
			delBooth(val,cateIndex,index){
				if(val.id){
		    		var _this=this;
			        _this.$confirm('此操作将永久删除该展位, 是否继续?', '提示', {
			          confirmButtonText: '确定',
			          cancelButtonText: '取消',
			          type: 'warning'
			        }).then(() => {
			        	$.getJSON('/job-fair/delJobFairBooth/'+val.id+'/0',function(ret){
			        		if (ret) {
			        			if (ret.code == 0) {
									_this.form.booth[cateIndex].sum--;
									_this.form.booth[cateIndex].boothCate.splice(index,1);
			        			}else{
			        				XYBase.msg(ret.msg);
			        			}
			        		}else{
								XYBase.error(XYBase.config.system_network_error);
			        		}
			        	});
			        }).catch(() => {
	    				XYBase.msg('已取消删除');
			        });
				}else{
					this.form.booth[cateIndex].sum--;
					this.form.booth[cateIndex].boothCate.splice(index,1);
				}
			},
			getAreaText(area) {
				var areaText='';
				for (var i = 0; i < this.arealist.length; i++) {
					if (area[0]===this.arealist[i].id) {
						areaText=areaText+this.arealist[i].title;
						for (var j = 0; j < this.arealist[i].data.length; j++) {
							if (area[1]===this.arealist[i].data[j].id) {
								areaText=areaText+this.arealist[i].data[j].title;
								for (var n = 0; n < this.arealist[i].data[j].data.length; n++) {
									
									if (area[2]===this.arealist[i].data[j].data[n].id)
									areaText=areaText+this.arealist[i].data[j].data[n].title;
								}
							}
						}
					}
				}
				return areaText;
			},
			handleAvatarSuccess:function(res, file) {
				if(res){
					if(res.code === 0){
						if(res.data.type == 'job_fair/thumb'){
							this.form.thumb=res.data.path;
							this.thumb=res.data.url;
						}else if(res.data.type == 'job_fair/banner'){
							this.form.banner=res.data.path;
							this.banner=res.data.url;
						}else if(res.data.type == 'job_fair/booth_img'){
							this.form.booth_img=res.data.path;
							this.booth_img=res.data.url;
						}
						XYBase.success(res.msg);
					}else{XYBase.error(res.msg);}
				}else{XYBase.error(XYBase.config.system_network_error)}
			},
			handleAvatarError:function(res, file) {
	          	XYBase.error(XYBase.config.system_network_error)
			},
			submitForm:function(formName) {
				var _this=this;
				var D={
					title:_this.form.title,
					thumb:_this.form.thumb,
					banner:_this.form.banner,
					booth_img:_this.form.booth_img,
					sign_up_start_time:_this.form.sign_up_start_time,
					sign_up_end_time:_this.form.sign_up_end_time,
					start_time:_this.form.start_time,
					end_time:_this.form.end_time,
					status:_this.form.status,
					nature:_this.form.nature,
					online_registration:_this.form.online_registration,
					tel_registration:_this.form.tel_registration,
					offline_registration:_this.form.offline_registration,
					sort:_this.form.sort,
					is_all_sign_up:_this.form.is_all_sign_up,
					booth_sum:_this.form.booth_sum,
					vip:_this.form.vip,
					booth:JSON.stringify(_this.form.booth),
					contacts:_this.form.contacts,
					job_fair_area:_this.form.job_fair_area,
					address:_this.form.address,
					lng:_this.form.lng,
					lat:_this.form.lat,
					transit:_this.form.transit,
					base_view:this.form.base_view,
					// base_company:this.form.base_company
					base_people_sum:this.form.base_people_sum
				};
				if(this.isSetAboutStatus){
					D.about=ueAbout.getContent();
				}else{
					D.about=formData.about;
				}
				if(this.isSetContentStatus){
					D.content=ue.getContent();
				}else{
					D.content=formData.content;
				}
				_this.$refs[formName].validate((valid) => {
				  if (valid) {
					const loading = XYBase.openloading();
					$.ajax({
						url:url,
						data:D,
						type:'post',
						dataType:'json',
						success:function(ret){
					        loading.close();
					        if (ret) {
								if(ret.code == 0){
									XYBase.success(ret.msg);
									if(!_this.is_edit){
										_this.resetForm(formName);
									}
								}else{
									XYBase.msg(ret.msg);
								}
					        }else{
				          		XYBase.error(XYBase.config.system_network_error)
					        }
						},
						error:function(err){
					        loading.close();
				          	XYBase.error(XYBase.config.system_network_error)
						}
					});
				  } else {
					XYBase.warning('请先把表单填写完整。');
				    return false;
				  }
				});
			},
			resetForm:function(formName) {
				this.$refs[formName].resetFields();
			},
		}
	});
$(function(){
	reloadWindowSize();
	$(window).resize(function(){
		reloadWindowSize();
	});
});
function reloadWindowSize (argument) {
	var winW=$(window).width();
	if(winW <= 576){
		vm.labelPosition='top';
	}else{
		vm.labelPosition='right';
	}
}
if (amapConfig.status && amapConfig.js_status && amapConfig.js_key) {
	var jsapi = document.createElement('script');
	jsapi.charset = 'utf-8';
	jsapi.src = '//webapi.amap.com/maps?v=2.0&key='+amapConfig.js_key;
	document.head.appendChild(jsapi);
}
function initAmap() {
	if (map!==null)return;
	var param={
               resizeEnable: true,
               zoom:15
            };
        if (vm.form.lng && vm.form.lat)
        	param.center=[parseFloat(vm.form.lng),parseFloat(vm.form.lat)];
    map = new AMap.Map('map_container', param);
    if (vm.form.lng && vm.form.lat)
    	setInfoWindow([parseFloat(vm.form.lng),parseFloat(vm.form.lat)]);
    AMap.plugin('AMap.Geolocation',function(){
        var Geolocation = new AMap.Geolocation();
        map.addControl(Geolocation);
    });
    map.on('click',function(ev) {
    	var lnglat=[ev.lnglat.KL,ev.lnglat.kT];
    	vm.form.lng=ev.lnglat.KL;
    	vm.form.lat=ev.lnglat.kT;
    	setInfoWindow(lnglat);
    })
}
function setInfoWindow(lnglat) {
    infoWindow = new AMap.InfoWindow({
        content: vm.$refs.infoWindow  //使用默认信息窗体框样式，显示信息内容
    });
    infoWindow.open(map, lnglat);
    AMap.Event.addListener(infoWindow, 'close', infoWindowClose)
}
function infoWindowClose() {
	vm.form.lng='';
	vm.form.lat='';
}
</script>
{/block}